package com.sunda.spmswms.service.impl;

import com.sunda.spmswms.entity.SapDeliveryNoteLog;
import com.sunda.spmswms.mapper.SapDeliveryNoteLogMapper;
import com.sunda.spmswms.service.ISapDeliveryNoteLogService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;
import java.util.UUID;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author Wayne
 * @since 2021-04-13
 */
@Service
public class SapDeliveryNoteLogServiceImpl extends ServiceImpl<SapDeliveryNoteLogMapper, SapDeliveryNoteLog> implements ISapDeliveryNoteLogService {

    @Autowired
    SapDeliveryNoteLogMapper sapDeliveryNoteLogMapper;

    @Override
    public void insertSapDeliveryNoteLog(SapDeliveryNoteLog sapDeliveryNoteLog) {
       sapDeliveryNoteLogMapper.insert(sapDeliveryNoteLog);
    }

    @Override
    public void insertSapDeliveryNoteLogM(String documentNumber, String userId, String comments) {
        SapDeliveryNoteLog sapDeliveryNoteLog = new SapDeliveryNoteLog();
        sapDeliveryNoteLog.setUuid(UUID.randomUUID().toString().replaceAll("-","").toLowerCase());
        sapDeliveryNoteLog.setDocumentNumber(documentNumber);
        sapDeliveryNoteLog.setUserid(userId);
        sapDeliveryNoteLog.setComments(comments);
        this.baseMapper.insert(sapDeliveryNoteLog);
    }

    @Override
    public void insertSapDeliveryNoteLogN(String documentNumber, String userId, String comments, String remarks) {
        SapDeliveryNoteLog sapDeliveryNoteLog = new SapDeliveryNoteLog();
        sapDeliveryNoteLog.setUuid(UUID.randomUUID().toString().replaceAll("-","").toLowerCase());
        sapDeliveryNoteLog.setDocumentNumber(documentNumber);
        sapDeliveryNoteLog.setUserid(userId);
        sapDeliveryNoteLog.setComments(comments);
        sapDeliveryNoteLog.setRemark(remarks);
        this.baseMapper.insert(sapDeliveryNoteLog);
    }

    @Override
    public List<Map<String, Object>> getDocumentLogs(String documentNumber) {
        return this.baseMapper.getDocumentLogs(documentNumber);
    }

    @Override
    public void insertSapRequestRecord(String documentNumber, String userId, String comments, String remarks, String requestParam) {
        SapDeliveryNoteLog sapDeliveryNoteLog = new SapDeliveryNoteLog();
        sapDeliveryNoteLog.setUuid(UUID.randomUUID().toString().replaceAll("-","").toLowerCase());
        sapDeliveryNoteLog.setDocumentNumber(documentNumber);
        sapDeliveryNoteLog.setUserid(userId);
        sapDeliveryNoteLog.setComments(comments);
        sapDeliveryNoteLog.setRemark(remarks);
        sapDeliveryNoteLog.setRequestParam(requestParam);
        this.baseMapper.insert(sapDeliveryNoteLog);
    }
}
